Skip to content

Fix internal error on TypeForm attribute access (fixes #4747) - #4818

Open
shobhitmehro wants to merge 1 commit into
facebook:mainfrom
shobhitmehro:fix/4747-typeform-attr-internal-error
Open

Fix internal error on TypeForm attribute access (fixes #4747)#4818
shobhitmehro wants to merge 1 commit into
facebook:mainfrom
shobhitmehro:fix/4747-typeform-attr-internal-error

Conversation

@shobhitmehro

Copy link
Copy Markdown
Contributor

accessing any attribute on a TypeForm[T] crashed pyrefly with an internal error since it had no attribute base defined. the fix falls back to object's attribute base and now resolves normally or gives an ordinary "no attribute" error instead of crashing

Fixes #4747

Test Plan

python3 test.py

@meta-cla meta-cla Bot added the cla signed label Sep 5, 2026
@github-actions github-actions Bot added the size/s label Sep 5, 2026
@shobhitmehro
shobhitmehro force-pushed the fix/4747-typeform-attr-internal-error branch from 26f9eaf to db5deb6 Compare September 5, 2026 01:28
@github-actions github-actions Bot added size/s and removed size/s labels Sep 5, 2026
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown

Diff from mypy_primer, showing the effect of this PR on open source code:

============================================================
SUMMARY
============================================================
Total: +6 new errors, -17 fixed errors
By preset: +5/-17 (default), +5/-17 (strict)

Projects with changes (1):
  beartype: +6 -17
============================================================

FULL DIFF DETAILS
------------------------------------------------------------

beartype (https://github.com/beartype/beartype)
- ERROR beartype/_check/cls/hint/hintsane.py:516:17-40: TODO: Expr::binop_infer attribute base undefined for type: TypeForm[Any] (trying to access __eq__) [internal-error]
- ERROR beartype/_check/convert/_reduce/_pep/pep484/redpep484ref.py:267:8-25: TODO: __bool__ attribute base undefined for type: TypeForm[Any] (trying to access __bool__) [internal-error]
- ERROR beartype/_check/convert/_reduce/redmain.py:368:16-54: TODO: Expr::binop_infer attribute base undefined for type: TypeForm[Any] (trying to access __eq__) [internal-error]
+ ERROR beartype/_util/hint/pep/proposal/pep484/pep484604union.py:150:31-32: Unused `# type: ignore` comment [unused-type-ignore]
- ERROR beartype/_util/hint/pep/proposal/pep484/pep484newtype.py:84:16-34: TODO: Expr::attr_infer_for_type attribute base undefined for type: TypeForm[Any] (trying to access __supertype__) [internal-error]
+ ERROR beartype/_util/hint/pep/proposal/pep484/pep484newtype.py:84:16-34: Object of class `object` has no attribute `__supertype__` [missing-attribute]
- ERROR beartype/_util/hint/pep/proposal/pep484/pep484typevar.py:275:8-24: TODO: __bool__ attribute base undefined for type: TypeForm[Any] (trying to access __bool__) [internal-error]
- ERROR beartype/_util/hint/pep/proposal/pep484585/generic/pep484585genfind.py:522:8-24: TODO: __bool__ attribute base undefined for type: TypeForm[Any] (trying to access __bool__) [internal-error]
- ERROR beartype/_util/hint/pep/proposal/pep484585/generic/pep484585genfind.py:957:12-28: TODO: __bool__ attribute base undefined for type: TypeForm[Any] (trying to access __bool__) [internal-error]
- ERROR beartype/_util/hint/pep/proposal/pep484585/generic/pep484585genfind.py:1037:8-24: TODO: __bool__ attribute base undefined for type: TypeForm[Any] (trying to access __bool__) [internal-error]
- ERROR beartype/_util/hint/pep/proposal/pep484585/generic/pep484585genget.py:863:44-57: TODO: Expr::attr_infer_for_type attribute base undefined for type: TypeForm[Any] (trying to access __call__) [internal-error]
+ ERROR beartype/_util/hint/pep/proposal/pep484585/generic/pep484585genget.py:863:44-57: Object of class `object` has no attribute `__call__` [missing-attribute]
- ERROR beartype/_util/hint/pep/proposal/pep586.py:203:12-25: TODO: Expr::attr_infer_for_type attribute base undefined for type: TypeForm[Any] (trying to access __args__) [internal-error]
+ ERROR beartype/_util/hint/pep/proposal/pep586.py:203:12-25: Object of class `object` has no attribute `__args__` [missing-attribute]
- ERROR beartype/_util/hint/pep/proposal/pep593.py:190:12-29: TODO: Expr::attr_infer_for_type attribute base undefined for type: TypeForm[Any] (trying to access __metadata__) [internal-error]
- ERROR beartype/_util/hint/pep/proposal/pep593.py:247:12-27: TODO: Expr::attr_infer_for_type attribute base undefined for type: TypeForm[Any] (trying to access __origin__) [internal-error]
+ ERROR beartype/_util/hint/pep/proposal/pep593.py:190:12-29: Object of class `object` has no attribute `__metadata__` [missing-attribute]
+ ERROR beartype/_util/hint/pep/proposal/pep593.py:247:12-27: Object of class `object` has no attribute `__origin__` [missing-attribute]
- ERROR beartype/_util/hint/pep/proposal/pep646/pep484585646tuple.py:144:9-40: TODO: Expr::binop_infer attribute base undefined for type: TypeForm[Any] (trying to access __eq__) [internal-error]
- ERROR beartype/_util/hint/pep/proposal/pep646/pep484585646tuple.py:145:9-40: TODO: Expr::binop_infer attribute base undefined for type: TypeForm[Any] (trying to access __eq__) [internal-error]
- ERROR beartype/_util/hint/pep/proposal/pep646/pep646692unpack.py:195:9-23: TODO: Expr::attr_infer_for_type attribute base undefined for type: TypeForm[Any] (trying to access __class__) [internal-error]
- ERROR beartype/_util/hint/pep/utilpepsign.py:418:17-31: TODO: Expr::attr_infer_for_type attribute base undefined for type: TypeForm[Any] (trying to access __class__) [internal-error]
- ERROR beartype/door/_cls/doormeta.py:138:21-25: Argument `TypeForm[Any]` is not assignable to parameter `key` with type `Hashable` in function `beartype._cache.cls.cacheclsmega.CacheMegaStrongCaller.cache_func_return_passed_arg` [bad-argument-type]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Internal error when accessing __annotations__ after typing.is_typeddict on a TypeForm

2 participants